<extend name="Application/Admin/View/Layout/application.html"/>

<block name="css">
    <style>
        #page2 {
            display: none;
        }
        #add_file{
            display: none;
        }
    </style>
</block>


<block name="content">
    <div class="row">
        <div class="col-md-12">

            <div class="row">
                <div class="col-md-8">
                    <div class="page-header">
                        <h1>文件管理</h1>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">File System</div>

                        <div class="panel-body">

                            <form action="" method="post" id="form">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>文件、目录名</th>
                                        <th>类型</th>
                                        <th>建立、修改时间</th>
                                        <th>大小</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <volist name="files" id="f">
                                        <tr>
                                            <td>
                                                {{$f.name}}
                                            </td>
                                            <td>{{$f.c_type}}</td>
                                            <td>{{$f.ctime|date="Y-m-d H:i",###}} / {{$f.mtime|date="Y-m-d H:i",###}}
                                            </td>
                                            <td>{{$f.size}}</td>
                                            <td>


                                                <a href="{{:U('destroy', array('path'=>$path.'/'.$f['name']))}}"
                                                   onclick="if(confirm('是否确定要删除!')==false) return false; ">删除</a>


                                                <eq name="f.type" value="file">
                                                    <a href="{{:U('download', array('path'=>$path.'/'.$f['name']))}}">下载</a>
                                                </eq>

                                                <if condition="$f.type eq 'dir'">
                                                    <a href="{{:U('index', array('path'=>$path.'/'.$f['name']))}}">进入</a>
                                                    <elseif condition="$f.is_image eq '1'"/>

                                                    <a href="{{:U('show', array('path'=>$path.'/'.$f['name']))}}">查看图片</a>

                                                    <elseif condition="$f.type eq 'file'"/>
                                                    <a href="{{:U('edit',array('path'=>$path.'/'.$f['name']))}}">编辑</a>
                                                </if>


                                            </td>
                                        </tr>
                                    </volist>
                                    </tbody>
                                </table>

                            </form>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <form enctype="multipart/form-data" method="post"  id="add_file" action="{{:U('upload', array('path'=>$path))}}" >
                        <input type="file" name="filename"   id="filename" />
                    </form>
                    <div class="list-group">
                        <a href="{{:U('add')}}" class="list-group-item list-group-item-info create_link">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 新增 (add)
                        </a>

                        <a href="javascript: void 0;" class="list-group-item list-group-item-info " id="add">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 上传文件 (add)
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>


</block>

<block name="js">
    <script>
        $(function(){
            $("#add").click(function () {
                $("#filename").click();
            })

            $("#filename").change(function () {
                $("#add_file").submit();
            })

        })
    </script>
</block>